using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.ComponentModel;

using GURUCORE.Framework.Core.Util.Localization;
using GURUCORE.Framework.Core.Util.Customization;

namespace GURUCORE.Portal.AspNet.Control.Localized
{    
    public class LocalizedPanel : Panel, ILocalizable
    {
        protected override void Render(HtmlTextWriter writer)
        {
            if (HttpContext.Current != null)
            {
                System.Web.UI.Control ctlNamingContainer = this.NamingContainer;
                if (ctlNamingContainer == null)
                {
                    base.Render(writer);
                    return;
                };
                while (!(ctlNamingContainer is UserControl || ctlNamingContainer is Page))
                {
                    ctlNamingContainer = ctlNamingContainer.NamingContainer;
                    if (ctlNamingContainer == null)
                    {
                        base.Render(writer);
                        return;
                    };
                }

                string sText = ResourceManager.GetString(ctlNamingContainer.GetType().BaseType.FullName, this.ID);
                if (sText != string.Empty)
                {
                    base.GroupingText = sText;
                }
            }
            base.Render(writer);
        }        
    }
}
